<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>

</template>

<script>
  import BScroll from 'better-scroll'

  export default {
    name: "Scroll",
    props: {
      probeType:{
        type:Number,
        default:0,
      },
      pullUpLoad: {
        type:Boolean,
        default:true,
      }
    },
    data() {
      return {
        scroll: null,
        message: '哈哈哈'
      }
    },

    mounted() {
      // 1.创建BScroll对象
      this.scroll = new BScroll(this.$refs.wrapper, {
        click: true,
        mouseWheel:true,
        probeType:this.probeType,
        pullUpLoad:this.pullUpLoad,
        observeImage:true,
        observeDOM:true,
        vague:false,
      })
      // console.log(this.scroll);
      this.scroll.on('scroll',position=>{
        this.$emit('scroll',position)
      })
      this.scroll.on('pullingUp',()=>{
        this.$emit('pullingUp')
      })


    },
    methods: {
      refresh() {
        this.scroll && this.scroll.refresh()
        // console.log('------')
      },
      scrollTo(x,y,time=300){
        this.scroll && this.scroll.scrollTo(x,y)
      },
      finishPullUp(){
        this.scroll && this.scroll.finishPullUp()
      }
    }
  }
</script>

<style scoped>

</style>
